package com.zzyl.mapper;

import com.github.pagehelper.Page;
import com.zzyl.entity.NursingLevel;
import com.zzyl.vo.NursingLevelVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface NursingLevelMapper {

    void insertNursingLevel(NursingLevel nursingLevel);

    void deleteNursingLevelById(Long id);

    void updateNursingLevel(NursingLevel nursingLevel);

    List<NursingLevelVo> selectAllNursingLevels();


    /**
     * 启用 禁用
     * @param id
     * @param status
     */
    @Update("update nursing_level set status = #{status} where id = #{id}")
    void updateStatus(@Param(value = "id")Long id, @Param(value = "status")Integer status);

    /**
     * 查询护理等级名称是否存在
     * @param name
     * @return
     */
    @Select("select count(*) from nursing_level where name = #{name}")
    Integer selectCountNurLevelName(String name);

    /**
     * 条件分页查询
     * @param name
     * @param status
     * @return
     */
    Page<NursingLevelVo> selectNursingLevelsByPage(@Param(value = "name")String name,@Param(value = "status") Integer status);

    /**
     * 根据id查询
     * @param id
     * @return
     */
    NursingLevelVo selectNursingLevelById(Long id);


    /**
     * 查询护理等级名称是否存在
     * @param
     * @return
     */
    @Select("select count(*) from nursing_level where name = #{name} and id != #{id}")
    Integer selectCountNurLevelNameExcludeId(@Param(value = "id")Long id, @Param(value = "name")String name);

    /**
     * 判断是否与老人表进行绑定
     * @param id
     * @return
     */
    Integer selectElderCountByLevelId(Long id);
}